package org.travel.app.common.myenum;

/**
 * @author nmm
 * @date 2024-12-2024/12/10
 * @deriction  预约类型的枚举类
 */
public enum ReservationType {
    HOTEL("hotel"),
    SPOT("spot");

    private final String value;

    ReservationType(String value) {
        this.value = value;
    }

    public String getValue() {
        return value;
    }

    /**
     * 用于通过类似键将相应的枚举实例取出
     * @param value :key
     * @return
     */
    public static ReservationType fromValue(String value) {
        for (ReservationType type : ReservationType.values()) {
            if (type.value.equals(value)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown reservation type: " + value);
    }
}